package com.dd.census.controller;

import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import com.dd.census.controller.common.BaseController;
import com.dd.census.entity.SysUserRole;
import com.dd.census.service.impl.SysUserRoleServiceImpl;

@Controller
@RequestMapping(value = "rest/sysUserRole")
public class SysUserRoleController extends BaseController {

	private static final Logger logger = LoggerFactory.getLogger(SysUserRoleController.class);

	@Autowired
	private SysUserRoleServiceImpl sysUserRoleService;

	@RequestMapping("/{id}")
	public ResponseEntity<Object> getById(@PathVariable("id") Integer id, HttpServletRequest request) {
		try {
			SysUserRole sysUserRole = new SysUserRole();
			sysUserRole.setUserId(id);
			
			return this.doSuccess(request, sysUserRoleService.selectByRoleId(sysUserRole));
		} catch (Exception e) {
			// 系统异常
			logger.error("Internal Server Error", e);
			return doFaild(request, HttpStatus.INTERNAL_SERVER_ERROR);
		}
	}
}